package tech.aistar.mapper;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import tech.aistar.entity.UserInfo;
import tech.aistar.entity.UserRelation;
import tech.aistar.util.IdWorker;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class UserRelationMapperTest {
    @Autowired
    private UserRelationMapper userRelationMapper;
    @Autowired
    private CollectionsMapper collectionsMapper;

    @Autowired
    private IdWorker idWorker;

    @Test
    public void test01(){
        UserRelation user = new UserRelation(Long.valueOf(idWorker.nextId()),1,null,12,0);
        userRelationMapper.addShip(user);
        System.out.println("===========================");
        List<UserRelation>list = userRelationMapper.findFansNum(1);
        //list.forEach(System.out::println);
        System.out.println(list.size());
    }
    @Test
    public void test02(){
        //关注的添加测试
        UserRelation user = new UserRelation(Long.valueOf(idWorker.nextId()),1,null,26,0);
        UserRelation user1 = new UserRelation(Long.valueOf(idWorker.nextId()),1,null,27,0);
        UserRelation user2 = new UserRelation(Long.valueOf(idWorker.nextId()),1,null,28,0);
        UserRelation user3 = new UserRelation(Long.valueOf(idWorker.nextId()),1,null,29,0);
        UserRelation user4 = new UserRelation(Long.valueOf(idWorker.nextId()),25,null,1,0);
        UserRelation user5 = new UserRelation(Long.valueOf(idWorker.nextId()),30,null,1,0);
        userRelationMapper.addShip(user);
        userRelationMapper.addShip(user1);
        userRelationMapper.addShip(user2);
        userRelationMapper.addShip(user3);
        userRelationMapper.addShip(user4);
        userRelationMapper.addShip(user5);
        //查找粉丝(被关注者在前面)
        List<UserRelation>list = userRelationMapper.findFansNum(1);
        System.out.println("-----------------------------");
        System.out.println(list.size());
        list.forEach(System.out::println);
    }

    @Test
    public void test03(){
        //查找关注者  我关注的
        List<UserRelation>list = userRelationMapper.findFoucNum(1);
        System.out.println(list.size());
        list.forEach(System.out::println);
    }

    @Test
    public void test04(){
        collectionsMapper.addGoods(1,20);
//        System.out.println(collectionsMapper.findByGood(1));

    }


}
